package org.jxc.web.action;

import java.util.Calendar;

import org.jxc.service.SalesOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.team4.web.action.GenericAction;

@Controller
@Scope("prototype")
public class SalesCountAction extends GenericAction<Object> {

	private static final long serialVersionUID = -8465525870762638814L;
	@Autowired
	private SalesOrderService salesOrderService;

	private int year;

	public SalesOrderService getSalesOrderService() {
		return salesOrderService;
	}

	public void setSalesOrderService(SalesOrderService salesOrderService) {
		this.salesOrderService = salesOrderService;
	}

	public String listPagination() throws Exception {
		if (year == 0) {
			Calendar ca = Calendar.getInstance();
			page = salesOrderService.getSalesCount(page, ca.get(Calendar.YEAR));
		} else {
			page = salesOrderService.getSalesCount(page, year);
		}
		return SUCCESS;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}
}
